package 算法.练习1;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

/**
 * @author:谢君臣
 * @Date:2021/7/16-10:14
 * @version:1.0
 * @function:
 */
public class 位运算 {
    public static void main(String[] args) {
        int a = 7, b = ~a;
        System.out.println(Integer.toBinaryString(a));
        System.out.println(b);
        System.out.println(Integer.toBinaryString(b));
        System.out.println(Integer.toBinaryString(-10));
        System.out.println(8 & -8);
        System.out.println(7 & -7);
        System.out.println(9 & -9);
        System.out.println(10 & -10);
        System.out.println(4 & -4);
        System.out.println(16 & -16);
        int[]res = new int[]{1,2,2,1,4,4,5,3,3};
        int temp = 0;
        for (int re : res) {
            System.out.println("---------------------------------");
            System.out.println(Integer.toBinaryString(re));
            System.out.println(Integer.toBinaryString(temp));
            temp = temp ^ re;
            System.out.println(Integer.toBinaryString(temp));

        }
        System.out.println(temp);

        String s = new String("asd");
        String s1 = new String("asd");
        System.out.println(s == s1);
        System.out.println(s.equals(s1));

        Set haset = new HashSet();
        haset.add(s);
        haset.add(s1);
        Iterator iterator = haset.iterator();
        while (iterator.hasNext()){
            System.out.println(iterator.next());
        }
    }
}
